<template>

  <div class="app-container">
    <el-form :inline="true" class="demo-form-inline">
      <el-form-item label="小区名">
        <el-input v-model="name" placeholder="请输入小区名称"></el-input>
      </el-form-item>


      <el-form-item>
        <el-button type="primary" @click="searchRoomOrder()">查询</el-button>
      </el-form-item>
    </el-form>

    <el-table
      :data="roomOrderList"
      stripe
      style="width: 100%">
      <el-table-column
        prop="id"
        label="id"
        width="70">
      </el-table-column>
      <el-table-column
        prop="quarters.name"
        label="小区名"
        width="120">
      </el-table-column>

      <el-table-column
        prop="user.userName"
        label="用户">
      </el-table-column>

      <el-table-column
        prop="time"
        label="时间">
      </el-table-column>
    </el-table>
    <div class="block">
      <el-pagination
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :page-sizes="[2,4,6,8]"
        :page-size="size"
        :total="total"
        :current-page.sync="num">
      </el-pagination>
    </div>
  </div>
</template>


<script>
import Room from '@/api/room.js'

export default {
  name: "RoomOrderList",
  data() {
    return {
      num: 1,
      size: 2,
      total: 0,
      roomOrderList: [],
      name: ''
    }
  },
  created() {
    this.initRoomOrder();
  },
  methods: {
    initRoomOrder() {
      Room.getRoomOrder(this.num,this.size,this.name).then(res => {
        const {data} = res
        this.roomOrderList = data.orderRoomList.list
        this.num = data.orderRoomList.pageNum;
        this.size = data.orderRoomList.pageSize;
        this.total = data.orderRoomList.total;
      })

    },
    searchRoomOrder(){
      this.initRoomOrder()
    },
    handleCurrentChange(num) {
      this.num = num
      this.initRoomOrder()
    },
    handleSizeChange(size) {
      this.num = 1
      this.size = size
      this.initRoomOrder()
    },

  }
}
</script>

<style scoped>


</style>
